Ext.define('TS.controller.General', {
	extend: 'Ext.app.Controller',

	models: [// TODO zgrupowac słowniki z kodami (do słownika)
		'User','AclRole','Denomination','Author','Language','Tag'
	],
	stores: [
	    'User','AclRole','Denomination','Author','Language','Tag'
	],
	views: [
		'general.Panel'
	],
	
	init: function() {
		this.control({
			'viewport > tabpanel' : {
               render: this.onStart,
               tabchange:this.onShow
            }
		});
	},
	
	onStart:function(tabpanel,x){
		tabpanel.add({xtype:'generalpanel'});
	},
	
	onShow:function(tabpanel,tab){

		if(tab.xtype=='generalpanel' && tab.items.length==0){

			Util.require([
			      'user.Form','user.Grid',
			      'aclrole.Form','aclrole.Grid',
			      'denomination.Form','denomination.Grid',
			      'author.Form','author.Grid',
			      'language.Form','language.Grid',
			      'tag.Form','tag.Grid'
			],function(){
				tab.add(
					
					Factory.layout.duoTab('Użytkownicy','user'),
					Factory.layout.duoTab('Role acl','aclrole'),
					Factory.layout.duoTab('Języki','language'),
					Factory.layout.duoTab('Tagi','tag'),
					Factory.layout.duoTab('Denominacje','denomination'),
					Factory.layout.duoTab('Autorzy','author')
				);
				Util.s.fillEach(
					Dict.user,Dict.aclrole,Dict.denomination,Dict.author,Dict.language,Dict.tag
				);
				
			},'TS.view.general');			
		};
	},
	
	util:{
		
	}
});